<%@ page contentType="text/html; charset=utf-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>爱购物-商城 - ${empty category ? "全部商品": category.name }</title>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/static/css/style.css"/>

</head>
<body>
<c:import url="/front/header">
    <c:param name="pid" value="${topCid}"/>
</c:import>
<div id="position" class="wrap">
    您现在的位置：<a href="${pageContext.request.contextPath}/index">爱购物-商城</a> &gt;
    <a href="${pageContext.request.contextPath}/product/list">商品分类</a> &gt; ${empty category ? "全部商品": category.name }
</div>
<div id="main" class="wrap">
    <c:import url="/front/lefter"/>
    <form id="list-search" action="${pageContext.request.contextPath}/product/list" method="get">
        <input id="pageNo" type="hidden" name="pageNo" value="">
        <input type="hidden" name="topCid" value="${topCid}">
        <input type="hidden" name="subCid" value="${subCid}">
    </form>
    <div class="main">
        <div class="product-list">
            <h2>${empty category ? "全部商品": category.name }</h2>
            <div class="clear"></div>
            <ul class="product clearfix">
                <c:forEach var="p" items="${page.rows}">
                    <li>
                        <dl>
                            <dt><a href="${pageContext.request.contextPath}/product?id=${p.id }" target="_blank"><img
                                    src="${pageContext.request.contextPath}${p.fileName }"/></a></dt>
                            <dd class="title"><a href="${pageContext.request.contextPath}/product?id=${p.id }"
                                                 target="_blank">${p.description }</a></dd>
                            <dd class="price">￥${p.price }</dd>
                        </dl>
                    </li>
                </c:forEach>
            </ul>
            <div class="clear"></div>
            <c:if test="${!empty page.rows || fn:length(page.rows)>0}">
                <div class="pager">
                    <ul class="clearfix">
                        <li>当前:${page.pageNo}/${page.pages }页</li>
                        <c:if test="${page.pageNo ne 1}">
                            <li><a href="javascript:jump(1)">首页</a></li>
                            <li><a href="javascript:jump(${page.pageNo-1 })">上一页</a></li>
                        </c:if>
                        <c:if test="${page.pageNo ne page.pages}">
                            <li><a href="javascript:jump(${page.pageNo+1 })">下一页</a></li>
                            <li><a href="javascript:jump(${page.pages })">尾页</a></li>
                        </c:if>
                        <li>
                            <select onchange="jump(this.value)">
                                <c:forEach var="i" begin="1" end="${page.pages}">
                                    <option ${i==page.pageNo ? "selected" : "" } value="${i}">${i }页</option>
                                </c:forEach>
                            </select>
                        </li>
                    </ul>
                </div>
            </c:if>
        </div>
    </div>
    <div class="clear"></div>
</div>
<c:import url="/static/page/footer.jsp"/>
<%--<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/function.js"></script>--%>
<script type="text/javascript">
    function jump(p) {
        document.getElementById("pageNo").value = p;
        document.getElementById("list-search").submit();
    }
</script>
</body>
</html>
